home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Interactive Web Graphics with Shout 3D
/
Interactive Web Graphics With Shout 3D.iso
/
mac
/
Code
/
Chapter09
/
ChangeSegmentsPanel.java
< prev
next >
Wrap
Text File
|
2000-08-27
|
2KB
|
75 lines
package applets;
import shout3d.*;
import shout3d.core.*;
import shout3d.math.*;
public class ChangeSegmentsPanel extends Shout3DPanel implements DeviceObserver {
TimeSensor timer;
ScalarInterpolator si;
float[] first = {0.0f, .19f};
float[] second = {.2f, 1.0f};
boolean firstseg = false;
public ChangeSegmentsPanel (Shout3DApplet applet){
super(applet);
}
public void customInitialize() {
addDeviceObserver(this,"MouseInput", null);
timer = (TimeSensor) getNodeByName("timer");
si = (ScalarInterpolator) getNodeByName("si");
}
protected void finalize() {
removeDeviceObserver(this,"MouseInput");
}
public boolean onDeviceInput(DeviceInput di, Object userData) {
MouseInput mi = (MouseInput) di;
switch (mi.which){
case MouseInput.DOWN:
if(firstseg) {
timer.loop.setValue(false);
timer.stop();
timer.cycleInterval.setValue(8.0);
si.keyValue.setValue(second);
timer.start();
timer.loop.setValue(true);
firstseg = false;
return true;
}
else {
timer.loop.setValue(false);
timer.stop();
timer.cycleInterval.setValue(2.0);
si.keyValue.setValue(first);
timer.start();
timer.loop.setValue(true);
firstseg = true;
return true;
}
}//end of switch
return false;
}
}//end of class